*---------------------------------------------------------------------------------------------
*
*By:  John B. Gilmour and David E. Lewis
*Date: May 26, 2003
*
*My hope is to read data into stata, combine it with political variables and do some analysis
*----------------------------------------------------------------------------------------------
*First, I need to do some housekeeping.
set memory 64000
set l 72
set level 95
set matsize 150

use partscores060803.dta

drop fy2002 fy2003 fy2004
*Now I will combine the data with the time-varying covariates in such a way that we save unmatched observations
joinby year using gilmourtv, unmatched(master)

*Now I will generate some summary statistics
summarize

*Now I will create some additional variables.

*I need to do a little cleaning of the departmentid variable. departmentid2 considers parts of DHS in their old departments since that is where they
*were when they were graded.  All independent agencies are considered a 15 on the departmentid2 numbering.  Only the corps of engineers still has
*an independent number (3).  What I am going to do is remake the department id variable to put the corps in the defense department.

generate departmentid3=departmentid2
replace departmentid3=4 if departmentid2==3
replace departmentid3=departmentid3-1 if departmentid3>3
tab departmentid3, generate (dep)


*Now program dummies and durationsq.
tab programtype, generate(prog)
generate dursq=duration*duration

*Now the budget variable logged.  I exclude government corporations here because their budgets are not a good indicator of size.

generate lnbudg=ln(budgetm) if budgetm>0

*First, what we should do is look at the dependent variable which is the total weighted, or overall, score and then look at the parts.
summarize totalweighted programresultsraw strategicplanningraw programmanagementraw programpurposeraw

*Next, we should look at the impact of the key independent variable on on the dependent variable.
*These are categorizations provided by OMB's own documents, rather than our attempts to attach program directors to programs.
summarize ca2 na2 pas2


more
clear
use partscores060803.dta



*I am going to add a few more dates collected by Gilmour.  We have a few concerns since some programs are administered
*in a different format than the were at their start.  The maternal child and health block grant is an example.

replace year=1938 if programid==105
replace year=1980 if programid==113
replace year=1996 if programid==115|programid==120|programid==162
replace year=1921 if programid==117
replace year=1935 if programid==119
replace year=1944 if programid==122
replace year=1965 if programid==126
replace year=1990 if programid==140
replace year=1992 if programid==158
replace year=1973 if programid==230

*I need to do a little cleaning of the departmentid variable. departmentid2 considers parts of DHS in their old departments since that is where they
*were when they were graded.  All independent agencies are considered a 15 on the departmentid2 numbering.  Only the corps of engineers still has
*an independent number (3).  What I am going to do is remake the department id variable to put the corps in the defense department.

generate departmentid3=departmentid2
replace departmentid3=4 if departmentid2==3
replace departmentid3=departmentid3-1 if departmentid3>3
tab departmentid3, generate (dep)

*Now to create a new duration variable to account for the additional data.
generate duration2=2003-year

*Now the budget variable logged.  I exclude government corporations here because their budgets are not a good indicator of size.
generate lnbudg=ln(budgetm) if budgetm>0



*Now I will combine the data with the time-varying covariates in such a way that we save unmatched observations
joinby year using gilmourtv, unmatched(master)

*Now I will generate some summary statistics
summarize

*Now I will create some additional variables.
*First are the dummies for programs.  
tab programtype, generate(prog)

*I create a new duration variable to account for the new data on year added above.
replace duration=2003-year
generate dursq=duration*duration
generate demcong=demhouse*demsen

*First, what we should do is look at the dependent variable which is the total weighted, or overall, score and then look at the parts.
summarize totalweighted programresultsraw strategicplanningraw programmanagementraw programpurposeraw

*Next, we should look at the impact of the key independent variable on on the dependent variable.
*These are categorizations provided by OMB's own documents, rather than our attempts to attach program directors to programs.
summarize ca2 na2 pas2

*I will generate a variable that is 0 for career SES, 1 for non-career SES or XS, and 2 for PAS.  There are 20 or so without bureaus.
generate apty3=0 if ca2==1
replace apty3=1 if na2==1
replace apty3=2 if pas2==1
replace apty3=1 if other2==1

twoway histogram programgrade, fraction discrete title("Figure 1. Categorical Grades Across Federal Programs") ylabel(0(.1).6) xtitle("") text(.1 0 "Ineffective") text(.55 1 "Results Not Demonstrated") text(.2 2 "Adequate") text(.3 3 "Moderately Effective") text(.1 4 "Effective")
graph bar (mean) programpurposeraw strategicplanningraw programmanagementraw programresultsraw totalweighted, title("Figure 2. Average Scores Across Federal Programs") ylabel(0(20)100) legend(label(1 "Program Purpose") label(2 "Strategic Planning") label(3 "Program Management") label (4 "Program Results") label (5 "Total Score"))
graph bar (mean) programpurposeraw strategicplanningraw programmanagementraw programresultsraw totalweighted, over(apty3, relabel(1 "Career SES" 2 "Non-Career SES" 3 "PAS Appointment")) legend(label(1 "Program Purpose") label(2 "Strategic Planning") label(3 "Program Management") label (4 "Program Results") label (5 "Total Score")) title("Figure 3. OMB Management Scores by Manager Type") ylabel(0(20)100) ytitle("PART Score")


graph hbar (mean) totalweighted, title("Figure 4. Total Score by Program Type") ylabel(0(20)100) ytitle("Total Weighted PART Score") over(programtype, relabel(1 "Block Grant" 2 "Credit" 3 "Acquisition" 4 "Competitive Grant" 5 "Direct Federal" 6 "Mixed" 7 "Regulatory" 8 "R&D")) 

graph hbar (mean) totalweighted, title("Figure 5. Total Score by Department") ylabel(0(20)100) ytitle("Total Weighted PART Score") over(departmentid3, relabel(1 "USDA" 2 "Commerce" 3 "DOD" 4 "Education" 5 "DOE" 6 "EPA" 7 "HHS" 8 "HUD" 9 "INT" 10 "DOJ" 11 "DOL" 12 "NASA" 13 "Other" 14 "State" 15 "DOT" 16 "Treasury" 17 "Veterans"))
*Now for the models
more

*First, with no controls for program type or department.
tobit programpurposeraw pas2 divided dempres demcong term duration, ul(100)
tobit strategicplanningraw pas2 divided dempres demcong term duration, ll(0) ul(100)
more
tobit programmanagementraw pas2 divided dempres demcong term duration, ul(100)
tobit programresultsraw pas2 divided dempres demcong term duration, ll(0)
regress totalweighted pas2 divided dempres demcong term duration, robust
oprobit programgrade pas2 divided dempres demcong term duration, robust

more

*Now with controls for program type and department.
tobit programpurposeraw pas2 divided dempres demcong term duration prog1-prog7 dep1-dep17 , ul(100)
tobit strategicplanningraw pas2 divided dempres demcong term duration prog1-prog7 dep1-dep17 , ll(0) ul(100)
more
tobit programmanagementraw pas2 divided dempres demcong term duration prog1-prog7 dep1-dep17 , ul(100)
tobit programresultsraw pas2 divided dempres demcong term duration prog1-prog7 dep1-dep17 , ll(0)
regress totalweighted pas2 divided dempres demcong term duration prog1-prog7 dep1-dep17 , robust
oprobit programgrade pas2 divided dempres demcong term duration prog1-prog7 dep1-dep17 , robust
more

*Now with the budget data which I exclude from most models just because it reduces the number of cases.
*Note that the first model exludes program type indicators for facilitate estimation.

tobit programpurposeraw pas2 divided dempres demcong term duration lnbudg dep1-dep17 if lnbudg>0, ul(100)
tobit strategicplanningraw pas2 divided dempres demcong term duration lnbudg prog1-prog7 dep1-dep17 if lnbudg>0, ll(0) ul(100)
more
tobit programmanagementraw pas2 divided dempres demcong term duration lnbudg prog1-prog7 dep1-dep17 if lnbudg>0, ul(100)
tobit programresultsraw pas2 divided dempres demcong term duration lnbudg prog1-prog7 dep1-dep17 if lnbudg>0, ll(0)
regress totalweighted pas2 divided dempres demcong term duration lnbudg prog1-prog7 dep1-dep17 if lnbudg>0, robust
oprobit programgrade pas2 divided dempres demcong term duration lnbudg prog1-prog7 dep1-dep17 if lnbudg>0, robust


*Now without program data since an LR Test of nested models could not reject the null of no improved fit in the last model.
tobit programpurposeraw pas2 divided dempres demcong term duration dep1-dep17 , ul(100)
tobit strategicplanningraw pas2 divided dempres demcong term duration dep1-dep17 , ll(0) ul(100)
more
tobit programmanagementraw pas2 divided dempres demcong term duration dep1-dep17 , ul(100)
tobit programresultsraw pas2 divided dempres demcong term duration dep1-dep17 , ll(0)
regress totalweighted pas2 divided dempres demcong term duration dep1-dep17 , robust
more

*For the word scores, 0 ineffective, 1 results not demonstrated, 2 adequate, 3 moderately effective, 4 effective.
